import { createRouter, createWebHashHistory, RouteRecordRaw } from "vue-router";
import Home from "../layout/home.vue";
import children from "./routerConfig";

const routes: RouteRecordRaw[] = [
  {
    path: "/",
    redirect: children[0].children
      ? children[0].children[0].path
      : children[0].path,
  },
  {
    path: "/",
    name: "Home",
    component: Home,
    children,
  },
];

const router = createRouter({
  history: createWebHashHistory(),
  routes: routes,
});

router.beforeEach((to, from, next) => {
  document.title = `vue3-template | ${to.meta.title}`;
  next();
});

export default router;
